<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>登录</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/static/plugins/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/admin/css/admin.css" media="all">
    <link rel="stylesheet" href="/static/admin/css/login.css" media="all">
</head>
<body class="login-bg">

<div class="layadmin-user-login layadmin-user-display-show" id="wycto-user-login">

    <div class="layadmin-user-login-main">
        <div class="layadmin-user-login-box layadmin-user-login-header">
            <h2>后台管理系统</h2>
            <p>后台业务数据管理</p>
        </div>
        <div id="login-form" class="layadmin-user-login-box layadmin-user-login-body layui-form">
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-username" for="wycto-user-login-username"></label>
                <input type="text" name="username" value="admin" id="wycto-user-login-username" lay-verify="required" placeholder="用户名" class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="wycto-user-login-password"></label>
                <input type="password" name="password" value="123456" id="wycto-user-login-password" lay-verify="required" placeholder="密码" class="layui-input">
            </div>
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-xs7">
                        <label class="layadmin-user-login-icon layui-icon layui-icon-vercode" for="wycto-user-login-vercode"></label>
                        <input type="text" name="captcha" id="wycto-user-login-vercode" lay-verify="required" placeholder="图形验证码" class="layui-input">
                    </div>
                    <div class="layui-col-xs5">
                        <div style="margin-left: 10px;">
                            <img src="/index/user/captcha" class="layadmin-user-login-codeimg" id="wycto-user-get-vercode">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <button id="login-btn" class="layui-btn layui-btn-fluid" lay-submit lay-filter="wycto-user-login-submit">登 录</button>
            </div>
        </div>
    </div>

    <div class="layui-trans layadmin-user-login-footer">
        <p>© 2020 <a href="http://www.wycto.com/" target="_blank">www.wycto.com</a></p>
    </div>
</div>

<script src="/static/plugins/layui/layui.js"></script>
<script>
    layui.use('form', function(){
        var $ = layui.$,form = layui.form;
        form.render();

        $(document).keydown(function(event){
            if (event.keyCode===13) {
                $("#login-btn").trigger("click");
            }
        });

        //提交
        form.on('submit(wycto-user-login-submit)', function(obj){
            $.post("/index/user/adminlogin",obj.field,function (res) {
                if(res.code){
                    //登入成功的提示与跳转
                    layer.msg(res.msg, {
                        offset: '15px'
                        ,icon: 1
                        ,time: 1000
                    }, function(){
                        location.href = "/admin/index/index"; //后台主页
                    });
                }else{
                    layer.alert(res.msg,{icon: 5});
                }
            },'json');
        });

        $("#wycto-user-get-vercode").click(function(){
            this.src = String('<?php echo url("/index/user/captcha",['r'=>'_RAND_'])?>').replace('_RAND_', Math.random());
            return false;
        });
    });
</script>
</body>
</html>